﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web;

namespace Yyyg.WebUI.Models
{
    public class GoodVM
    {
        [Display(Name = "标题")]
        [MaxLength(100, ErrorMessage = "标题长度不能大于100")]
        [Required]
        public string Title { get; set; }

        [Display(Name = "价值")]
        [Range(1, double.MaxValue, ErrorMessage = "价格区间不合法")]
        [DataType(DataType.Currency)]
        [Required]
        public double Price { get; set; }

        [DisplayName("夺宝人次")]
        [Range(1, int.MaxValue, ErrorMessage = "夺宝人次必须大于0")]
        [Required]
        public int NeedAmount { get; set; }

        [Display(Name = "分类ID")]
        [Required]
        public int Typeid { get; set; }

        [Display(Name = "库存")]
        [Required]
        public int Stock { get; set; }

        [MinLength(1, ErrorMessage = "至少添加一张展示图片")]
        [Display(Name = "展示图片")]
        [Required]
        public HttpPostedFileBase[] Mainimg { get; set; }

        [MinLength(1, ErrorMessage = "至少添加一张附属图片")]
        [Display(Name = "附属图片")]
        [Required]
        public HttpPostedFileBase[] Subimgs { get; set; }

        [MinLength(1, ErrorMessage = "至少添加一张详情图片")]
        [Display(Name = "详细信息图片")]
        [Required]
        public HttpPostedFileBase[] Detimgs { get; set; }

        [Display(Name = "简介")]
        [Required]
        [DataType(DataType.Text)]
        public string Brin { get; set; }

        [Display(Name = "上架")]
        public bool Enable { get; set; }

        public string Guid { get; set; }

        public bool SetDefaule { get; set; }

        public string[] DetImgs_URL { get; set; }

        public string[] SubImgs_URL { get; set; }

        public string Mainimg_URL { get; set; }

        public string[] SubDelFiles { get; set; }

        public string[] DetDelFiles { get; set; }

        public GoodVM()
        {
            Title = "商品标题";
            Price = 0.0;
            Stock = 0;
            Typeid = 1;
            Enable = true;
            Brin = "暂无简介";
            SetDefaule = false;
            Guid = "";
            Mainimg_URL = "";
            DetImgs_URL = new string[0];
            SubImgs_URL = new string[0];
        }
    }
}